#include <stdio.h>
#include <stdlib.h>

#include "common.h"
#include "Job.h"
#include "Node.h"
#include "List.h"


int main(int argc, char **argv) {
	int i;
	int n;
	NodePtr node;
	JobPtr job;
	ListPtr list;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <list size> \n<list size>: integer > 0\n", argv[0]);
		exit(1);
	}
	n = atoi(argv[1]);
	
	//ADDED BY LOUIS
	//Exit if argument isn't greater than 0
	if(n < 1){
	    fprintf(stderr, "Usage: %s <list size> \n<list size>: integer > 0\n", argv[0]);
	    exit(1);
	}

	list = createList();
	for (i = 0; i < n; i++) {
		job = createJob(i, "cmd args");
		node = createNode(job);
		addAtRear(list, node);
	}

	printList(list);
	printf("\nHead: %p, Tail: %p\n",list->head,list->tail); //Custom code I added (Louis) just to keep track of my Head and Tail variables to make sure they are working.
	
	reverseList(list);
	printf("\nHead: %p, Tail: %p\n",list->head,list->tail); //Custom code I added (Louis) just to keep track of my Head and Tail variables to make sure they are working.
	
	printList(list);
	printf("\nHead: %p, Tail: %p\n",list->head,list->tail); //Custom code I added (Louis) just to keep track of my Head and Tail variables to make sure they are working.
	
	removeNode(list,list->head->next);
	removeNode(list,list->head->next);
	
	
	
	
	/*
	reverseList(list);
	printf("\nHead: %p, Tail: %p\n",list->head,list->tail); //Custom code I added (Louis) just to keep track of my Head and Tail variables to make sure they are working.
	*/
	printList(list);
	printf("\nHead: %p, Tail: %p\n",list->head,list->tail); //Custom code I added (Louis) just to keep track of my Head and Tail variables to make sure they are working.
	

	freeList(list);

	exit(0);
}
